//
//  PPCategorySectionHeadView.m
//  PPDL
//
//  Created by 王洋 on 2019/10/17.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "PPCategorySectionHeadView.h"

@interface PPCategorySectionHeadView ()

@property (nonatomic, strong) UIView *leftView;
@property (nonatomic, strong) UIView *rightView;

@property (nonatomic, strong) UIView *distanceView;

@end

@implementation PPCategorySectionHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = UIColorHex(0xffffff);
        [self layout];
    }
    return self;
}

- (void)layout {
    
    [self addSubview:self.itemTitle];
    [self addSubview:self.leftView];
    [self addSubview:self.rightView];
    
    [self.itemTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.centerX.mas_equalTo(0);
    }];
    
    [self.leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.itemTitle.mas_left).offset(-10);
        make.centerY.mas_equalTo(self.itemTitle);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(1);
    }];
    
    [self.rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.itemTitle.mas_right).offset(10);
        make.centerY.mas_equalTo(self.itemTitle);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(1);
    }];
    
}

- (void)fillHeadWithModel:(PPCategoryModel *)model {
    
    self.itemTitle.text = [NSString stringWithFormat:@"%@",model.itemTitle];
}

- (UILabel *)itemTitle {
    
    if (!_itemTitle) {
        _itemTitle = [[UILabel alloc] init];
        _itemTitle.font = [UIFont systemFontOfSize:14];
        _itemTitle.textColor = UIColorHex(0x555555);
        _itemTitle.text = @"平板电脑";
    }
    return _itemTitle;
}

- (UIView *)leftView {
    if (!_leftView) {
        _leftView = [[UIView alloc] init];
        _leftView.backgroundColor = UIColorHex(0xcccccc);
    }
    return _leftView;
}

- (UIView *)rightView {
    if (!_rightView) {
        _rightView = [[UIView alloc] init];
        _rightView.backgroundColor = UIColorHex(0xcccccc);
    }
    return _rightView;
}

- (UIView *)distanceView {
    if (!_distanceView) {
        _distanceView = [[UIView alloc] init];
        _distanceView.backgroundColor = [UIColor blackColor];
    }
    return _distanceView;
}

@end
